#!/usr/bin/env python
# LEAVE THE FOLLOWING TWO LINES
# GAME BAKER
# yaml
# 0
s = """
!!python/object:game.Game
gameobjects:
  ball: &id001 !!python/object:game.GameObject
    baseworkstate: WSball
    name: ball
    objtype: Gameobject
    requires: []
    sprite: ballspr
  bat: &id002 !!python/object:game.GameObject
    baseworkstate: WSpaddle1
    name: bat
    objtype: Gameobject
    requires: []
    sprite: paddlespr
  bat2: &id003 !!python/object:game.GameObject
    baseworkstate: WSpaddle2
    name: bat2
    objtype: Gameobject
    requires: []
    sprite: paddlespr
  score: &id004 !!python/object:game.GameObject
    baseworkstate: WSscore
    name: score
    objtype: Gameobject
    requires: []
    sprite: null
gamescreens:
  Pongscreen: !!python/object:game.GameScreen
    dimensions: !!python/tuple [800, 600]
    objtype: Gamescreen
    startobjects:
    - *id001
    - *id002
    - *id003
    - *id004
initcode: ''
objtype: Game
sprites:
  ballspr: !!python/object:game.Sprite
    alphakey: !!python/tuple [0, 255, 0]
    framerate: 20
    imagefiles:
    - bottomright: !!python/tuple [25, 25]
      filename: sprites/images/ball.bmp
      topleft: !!python/tuple [0, 0]
    name: ballspr
    objtype: Sprite
  paddlespr: !!python/object:game.Sprite
    alphakey: !!python/tuple [0, 255, 0]
    framerate: 20
    imagefiles:
    - bottomright: !!python/tuple [15, 75]
      filename: sprites/images/paddle.bmp
      topleft: !!python/tuple [0, 0]
    name: paddlespr
    objtype: Sprite
startscreen: Pongscreen
title: Gamebaker - pong
workstates:
  WSball: !!python/object:game.WorkState
    actions: {1: '

        self.x=400

        self.y=300

        self.vx=200

        self.vy=0

        self.resize(25,25)', 3: "\\nself.move_velocity()\\n\\nif gamescreen.check_collisions(\\"\\
        ball\\",\\"bat\\"):\\n    self.vy += 2*(gamescreen.get_object('ball').y-(gamescreen.get_object('bat').y))\\n\\
        \\    #The height of a paddle is 75 pixels, the ball deflects from the 'center'\\n\\
        \\    self.vx = -self.vx\\n    # Do this or the sprites will overlap\\n    self.move_velocity()\\n\\
        \\nelse:\\n    if gamescreen.check_collisions(\\"ball\\",\\"bat2\\"):\\n        self.vy\\
        \\ += 2*(gamescreen.get_object('ball').y-(gamescreen.get_object('bat2').y))\\n\\
        \\        self.vx = -self.vx\\n        # Do this or the sprites will overlap\\n\\
        \\        self.move_velocity()\\n", 9: "\\nif (self.y < 0) or (self.y > 600):\\n\\
        \\tself.vy = -self.vy\\n\\nif (self.x < 0) or (self.x > 800):\\n    if self.x\\
        \\ < 0:\\n        game.score -=1\\n    elif self.x > 800:\\n        game.score\\
        \\ +=1\\n    self.x=400\\n    self.y=300\\n    self.vy=0\\n"}
    inherits: null
    objtype: Workstate
  WSpaddle1: !!python/object:game.WorkState
    actions: {-548: '

        self.vy = 0

        ', -546: '

        self.vy = 0

        ', 1: '

        self.x = 10

        self.y = 300

        self.vx = 0

        self.vy = 0

        self.resize(15,75)

        ', 3: '

        self.move_velocity()

        ', 546: '

        self.vy = -150

        ', 548: '

        self.vy = 150

        '}
    inherits: null
    objtype: Workstate
  WSpaddle2: !!python/object:game.WorkState
    actions: {1: '

        self.x = 765

        self.y = 300

        self.vx= 0

        self.vy = 0

        self.resize(15,75)

        ', 3: "\\nfrom random import randint\\nby = gamescreen.get_object('ball').y\\n\\
        \\nif game.score < -5:\\n\\tscore = -5\\nelse:\\n\\tscore = game.score\\n#The enemy\\
        \\ paddle might go the wrong way with a low score\\nif self.y+34 < by-5:\\n\\t\\
        self.vy = 150 + randint(-3,3) + score\\nelif self.y+34 > by+5:\\n\\tself.vy =\\
        \\ -150 + randint(-3,3) - score\\nelse:\\n\\tself.vy = 0\\nself.move_velocity()\\n\\
        \\n"}
    inherits: null
    objtype: Workstate
  WSscore: !!python/object:game.WorkState
    actions: {1: '

        self.x = 0

        self.y = 0

        self.color=(255,255,255)

        self.resize(70,25)

        ', 3: '

        self.clear()

        self.draw_text(game.score,28,(0,0,255))


        '}
    inherits: null
    objtype: Workstate

"""
if __name__ == "__main__":
  import gbfileio,sys,runtime
  game = gbfileio.loadgame(sys.argv[0])
  runtime.run_game(game)
